<template>
	<view>
		<aoEditer ref="page1" :page="pageConfig" class="aoedit" style="width: 100%;">
		</aoEditer>
	</view>
</template>

<script>
	import aoEditer from '@/components/common/aoEditer.vue'
	export default {
		components: {
			aoEditer,
		},
		data() {
			return {
				pageConfig: {},
				page_name: '',
			}
		},
		// onLoad(opt) {
		// 	uni.setNavigationBarTitle({
		// 		title:opt.name
		// 	});
		// 	this.page_name=opt.name;
		// 	this.pageConfig=this.$comm.get_page(opt.name);
		// 	console.log("page.onload",this.pageConfig);
		// },
		onLoad(opt) {

			if (opt.name) {
				uni.setStorageSync('page_name', opt.name);
			} else {
				opt.name = uni.getStorageSync('page_name')
			}
			uni.setNavigationBarTitle({
				title: opt.name
			});
			this.page_name = opt.name;
			this.pageConfig = this.$comm.get_page(opt.name);
			console.log("page.onload", this.pageConfig);
		},
		onPullDownRefresh() {
			console.log('refresh');
			this.update_page();
		},
		onNavigationBarButtonTap(e) {
			console.log("onNavigationBarButtonTap",e);
			this.update_page();
		},
		methods: {
			update_page() {
				let self = this;
				this.$comm.get_appPages(function(res) {
					console.log("update_page", res);
					self.pageConfig = res;
					self.$refs.page1.setPageConfig(res);
					uni.setStorageSync("page_" + self.page_name, res);
					uni.stopPullDownRefresh();

				}, false, this.page_name);
			}
		}
	}
</script>

<style>
	.aoedit {
		position: relative;
		height: 100vh;
		/* overflow-y: scroll; */
	}

	/deep/.body {
		width: 100% !important
	}
</style>